<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.29
     from clp.tnf on 19 December 2010 -->

<TITLE>Command Line Processing - Accessing the command line</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000" BACKGROUND="gifs/bg.gif">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0" VALIGN=BOTTOM>
<TR VALIGN=BOTTOM>
<TD WIDTH="160" VALIGN=BOTTOM>
<A HREF="http://eli-project.sourceforge.net/">
<IMG SRC="gifs/elilogo.gif" BORDER=0>
</A>&nbsp;
</TD>
<TD WIDTH="25" VALIGN=BOTTOM>
<img src="gifs/empty.gif" WIDTH=25 HEIGHT=25>
</TD>
<TD ALIGN=LEFT WIDTH="475" VALIGN=BOTTOM>
<A HREF="index.html"><IMG SRC="gifs/title.png" BORDER=0></A>
</TD>
<!-- |DELETE FOR SOURCEFORGE LOGO|
<TD>
<a href="http://sourceforge.net/projects/eli-project">
<img
  src="http://sflogo.sourceforge.net/sflogo.php?group_id=70447&amp;type=13"
  width="120" height="30"
  alt="Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads"/>
</a>
</TD>
|DELETE FOR SOURCEFORGE LOGO| -->
</TR>
</TABLE>

<HR size=1 noshade width=785 align=left>
<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TD VALIGN=TOP WIDTH="160">
<h4>General Information</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="index.html">Eli: Translator Construction Made Easy</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gindex_1.html#SEC1">Global Index</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="faq_toc.html" >Frequently Asked Questions</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Tutorials</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="EliRefCard_toc.html">Quick Reference Card</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="novice_toc.html">Guide For new Eli Users</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="news_toc.html">Release Notes of Eli</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="nametutorial_toc.html">Tutorial on Name Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="typetutorial_toc.html">Tutorial on Type Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Reference Manuals</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ui_toc.html">User Interface</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="pp_toc.html">Eli products and parameters</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lidoref_toc.html">LIDO Reference Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Libraries</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lib_toc.html">Eli library routines</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="modlib_toc.html">Specification Module Library</a></td></tr>
</table>

<h4>Translation Tasks</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lex_toc.html">Lexical analysis specification</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="syntax_toc.html">Syntactic Analysis Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="comptrees_toc.html">Computation in Trees</a></td></tr>
</table>

<h4>Tools</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lcl_toc.html">LIGA Control Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="show_toc.html">Debugging Information for LIDO</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gorto_toc.html">Graphical ORder TOol</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="fw_toc.html">FunnelWeb User's Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ptg_toc.html">Pattern-based Text Generator</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="deftbl_toc.html">Property Definition Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="oil_toc.html">Operator Identification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="tp_toc.html">Tree Grammar Specification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="clp_toc.html">Command Line Processing</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="cola_toc.html">COLA Options Reference Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="idem_toc.html">Generating Unparsing Code</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="mon_toc.html">Monitoring a Processor's Execution</a> </td></tr>
</table>

<h4>Administration</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="sysadmin_toc.html">System Administration Guide</a> </td></tr>
</table>

<HR WIDTH="100%">
<A HREF="mailto:eli-project-users@lists.sourceforge.net">
<IMG SRC="gifs/button_mail.gif" BORDER=0 ALIGN="left"></A>
<A HREF="index.html"><IMG SRC="gifs/home.gif" BORDER=0 ALIGN="right"></A>

</TD>
<TD VALIGN=TOP WIDTH="25"><img src="gifs/empty.gif" WIDTH=25 HEIGHT=25></TD>

<TD VALIGN=TOP WIDTH="600">
<H1>Command Line Processing</H1>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_3.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_5.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
<H1><A NAME="SEC15" HREF="clp_toc.html#SEC15">Accessing the command line</A></H1>
<P>
A CLP specification is turned into code that arranges for command line
information to be stored in C variables or a simple database.  This code
is automatically run by the processor startup code generated by Eli.
During attribution of a structure tree you can access the variables or
use access functions to obtain the command-line information.
<P>
The header file <TT>`clp.h'</TT> will contain <CODE>extern</CODE> declarations for
all values defined by the CLP-generated code.  It should be included
wherever these values must be accessed.
<P>
<H2><A NAME="SEC16" HREF="clp_toc.html#SEC16">Accessing boolean options</A></H2>
<P>
Since boolean options do not have value information associated with
them, all that is needed to represent them is a simple flag rather than
a database object.  We store the flag as a C integer variable whose name
is the option name.
<P>
For example, given the specification:
<P>
<PRE>
GenAssembly "-S" boolean;
</PRE>
CLP will generate a variable called <CODE>GenAssembly</CODE>.  Typical C code
to test for this option would look like:
<P>
<PRE>
if (GenAssembly)
  printf ("GenAssembly specified\n");
else
  printf ("GenAssembly not specified\n");
</PRE>
<P>
<H2><A NAME="SEC17" HREF="clp_toc.html#SEC17">Accessing options with integer values</A></H2>
<P>
To provide access to integer value options, CLP generates a database
object which has the appropriate value as a property.  The object is
referred to by a key-valued variable named after the option.  For
example, given the specification:
<P>
<PRE>
NumCopies "-#" int;
</PRE>
CLP will generate a variable called <CODE>NumCopies</CODE>.  The value of the
variable can be used to access the option value using the
<CODE>GetClpValue</CODE>
<A NAME="IDX50"></A>
property access function.
<P>
<PRE>
printf ("NumCopies value is %d\n", GetClpValue (NumCopies, 0));
</PRE>
Here <CODE>0</CODE> will be printed if the option was not specified by the user.
<P>
Alternatively, presence of the option can be tested for explicitly by
testing the key:
<A NAME="IDX51"></A>
<P>
<PRE>
if (NumCopies == NoKey)
  printf ("NumCopies not specified\n");
else
  printf ("NumCopies value is %d\n", GetClpValue (NumCopies, 0));
</PRE>
In this case the default value parameter in the <CODE>GetClpValue</CODE> call
will never be used.
<P>
<H2><A NAME="SEC18" HREF="clp_toc.html#SEC18">Accessing options with string values</A></H2>
<P>
Access to string value options is provided via a database object which
has the appropriate value as a property.  The object is referred to by a
key-value variable named after the option.  For example, given the
specification:
<P>
<PRE>
TmpFile "-temp=" joinedto string;
</PRE>
CLP will generate a variable called <CODE>TmpFile</CODE>.  <CODE>GetClpValue</CODE>
<A NAME="IDX52"></A>
is used to obtain the value which should be interpreted as a string
table index (see  <A HREF="lib_1.html#SEC6">Arbitrary-length character strings of Library Reference</A>).
<A NAME="IDX54"></A>
<A NAME="IDX53"></A>
<P>
<PRE>
#include "csm.h"

if (TmpFile == NoKey)
  printf ("TmpFile not specified\n");
else
  printf ("TmpFile value is '%s'\n", StringTable (GetClpValue (TmpFile, 0)));
</PRE>
<P>
<H2><A NAME="SEC19" HREF="clp_toc.html#SEC19">Accessing options that appear more than once</A></H2>
<P>
The mechanisms described in the previous three sections only apply to
options that can appear at most once on the command line.  More
complicated mechanisms are needed to access values associated with
repeated options.
<A NAME="IDX55"></A>
<P>
CLP uses linked lists of definition table keys
<A NAME="IDX56"></A>
to provide multiple value access.  The lists are implemented using Eli's
<CODE>List</CODE> module.
See  <A HREF="adt_2.html#SEC2">list of Specification Module Library: Abstract Data Types</A>.
<P>
Given the specification:
<P>
<PRE>
MacroPackage "-m" joinedto strings;
</PRE>
the list module lets you print the multiple values (via keys) as
follows:
<A NAME="IDX57"></A>
<P>
<PRE>
#include "csm.h"
#include "clp.h"

DefTableKey printkey (DefTableKey k)
{
    printf ("%s", StringTable (GetClpValue (k, 0)));
}

(void) MapDefTableKeyList (MacroPackage, printkey);
</PRE>
<P>
Boolean repeated options are an exception to this list approach.  Since
no value is associated with the option there is little point in having a
list of keys.  For this reason, boolean repeated options are implemented
as a single integer whose value is the number of times the option
appeared.
<A NAME="IDX59"></A>
<A NAME="IDX58"></A>
<P>
<H2><A NAME="SEC20" HREF="clp_toc.html#SEC20">Accessing positional parameters</A></H2>
<P>
For each singular positional parameter specification line CLP generates
a variable of the appropriate name which holds the key to a database
object which has the string value of the positional parameter as a
property.  The value can be accessed as for string value options
(see  <A HREF="clp_4.html#SEC18">Accessing options with string values</A>).  
<P>
CLP will always make sure that a positional parameter is specified and
will arrange for a usage message to be printed otherwise.
<A NAME="IDX60"></A>
Thus there is no need to test that the database object described in the
previous paragraph is defined.  For example, given the specification
line:
<P>
<PRE>
FileName positional;
</PRE>
the following code can be used to print the specified value:
<P>
<PRE>
#include "csm.h"

printf ("Filename given was '%s'\n", StringTable (GetClpValue (FileName, 0)));
</PRE>
<P>
When a plural positional parameter specification line is given the
mechanisms used for repeated option values are used (see  <A HREF="clp_4.html#SEC19">Accessing options that appear more than once</A>).  For example, if a processor can take multiple input files a
specification like the following might be used:
<P>
<PRE>
FileNames positionals;
</PRE>
The following code can be used to print these parameters
See  <A HREF="adt_2.html#SEC2">Linear Lists of Any Type of Specification Module Library: Abstract Data Types</A>.
<P>
<PRE>
#include "csm.h"
#include "clp.h"

DefTableKey printkey (DefTableKey k)
{
    printf ("%s", StringTable (GetClpValue (k, 0)));
}

(void) MapDefTableKeyList (FileNames, printkey);
</PRE>
<A NAME="IDX61"></A>
<P>
Since an input parameter is just a special kind of positional parameter,
its value can also be accessed as shown above.
<P>
<HR size=1 noshade width=600 align=left>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_3.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_5.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="clp_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
</TD>
</TR>
</TABLE>

</BODY></HTML>
